public class Add {
    public void Add(int[][] a, int[][] b) {

        int c[][] = new int[a.length][a[0].length];

        if (a.length != b.length || a[0].length != b[0].length)
            System.out.println("矩阵不能相加");
        else {
            System.out.println("两矩阵相加为：");
            for (int i = 0; i < a.length; i++) {
                for (int j = 0; j < a[0].length; j++) {
                    int item = a[i][j] + b[i][j];

                    c[i][j] = item;
                    System.out.print(c[i][j] + "  ");

                }

                System.out.println();

            }

        }
    }
}
